<template>
	<view>
		<view class="content" v-for="(item,index) in msgList" @click="goPage(item)">

			<view>
				<view class="title">
					<view style="width: 500rpx;">
						<text>{{item.title}}</text>
					</view>
					<view class="tag">
						<u-tag :text="item.status==0?'未读':'已读'" :type="item.status==0?'error':'success'" size="mini">
						</u-tag>
					</view>
				</view>

				<view class="xContent">
					<text>{{item.content}}</text>
				</view>
				<view class="border"></view>
			</view>
			<view class="time">

				{{getTime(item.createTime)}}
			</view>
		</view>
		<uni-load-more :status="status" :icon-size="14" :content-text="contentText" />
	</view>
</template>

<script>
	import SOtime from '../../js_sdk/fl-SOtime/SOtime.js'
	export default {
		data() {
			return {
				msgList: [],
				ifBottomRefresh: false,
				status: 'more',
				contentText: {
					contentdown: '上拉加载更多~',
					contentrefresh: '加载中',
					contentnomore: '暂无更多~'
				},
				params: {
					pageNo: 1,
					pageSize: 10,
					url: "",
				},
			}
		},
		onShow() {
			this.params = {
					pageNo: 1,
					pageSize: 10,
					url: "",
				},		
			this.getList()
		},
		onLoad(e) {
			// this.getList();
		},

		//触底加载状态
		onReachBottom() {
			if (this.status != 'noMore') {
				console.log("触底")
				this.status = 'loading';
				this.ifBottomRefresh = true
				//正式服去掉这个延时器
				this.getList()
			}
		},
		methods: {
			getTime(time) {
				return SOtime.time1(time)
			},
			getList() {
				this.$axios({
					url: "user/info/myMessage",
					method: "post",
					data: {
						pageNo: this.params.pageNo,
						pageSize: this.params.pageSize,
					}
				}).then((res) => {
					//请求接口成功之后，判断加载状态，处理数据
					if (res.result.pages >= this.params.pageNo) {
						if (this.ifBottomRefresh) {
							this.msgList = this.msgList.concat(res.result.list)
						} else {
							this.msgList = res.result.list
						}

					} else {
						this.status = 'noMore'
					}
					if (this.params.pageNo >= res.result.pages) {
						this.status = 'noMore'
					}
					this.params.pageNo++;
				})
			},
			goPage(value) {
				console.log("1231")
				uni.navigateTo({
					url: "./messageDetail?title=" + value.title + "&id=" + value.id + "&content=" + value.content +
						"&time=" + SOtime
						.time2(value.createTime),
				})
			}
		}
	}
</script>

<style lang="scss">
	.content {
		display: flex;
		padding: 25rpx;
		background-color: #fff;

		.border {
			border-style: solid;
			border-width: 1rpx;
			border-left: none;
			border-bottom: none;
			border-color: #afafaf2e;
			border-right: none;
			width: 600rpx;
			margin-top: 25rpx;
			position: absolute;
		}
	}

	.title {
		display: flex;
		font-size: 35rpx;
		color: #587dab;
		font-weight: 900;

		.tag {
			margin-left: 20rpx;
			font-size: 10rpx;
		}
	}

	.xContent {
		width: 600rpx;
		font-size: 25rpx;
		margin-top: 15rpx;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
		font-weight: 600;
		color: #7d7d7d;

	}

	.time {
		margin-right: auto;
		margin-left: auto;
		color: #0000004d;
		font-size: 20rpx;
	}
</style>
